package com.lt.bcra.controller.questionnaire;


import com.lt.bcra.entity.BcraGeneTest;
import com.lt.bcra.exception.BaseException;
import com.lt.bcra.service.BcraGeneTestService;
import com.lt.bcra.result.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 基因检测表 前端控制器
 * </p>
 *
 * @author LuoTian
 * @since 2022-05-25
 */
@Api(tags = "6.基因检测表")
@CrossOrigin //跨域可以前端配置
@RestController
@RequestMapping("bcra/geneTest")
public class BcraGeneTestController {
    private static Logger log = LoggerFactory.getLogger(BcraGeneTestController.class);

    @Autowired
    private BcraGeneTestService bcraGeneTestService;


    @PostMapping("/creatGeneTest")
    @ApiOperation("填写基因检测")
    @ApiParam(value = "bcraGeneTestList")
    public ResultData creatNew(@RequestBody List<BcraGeneTest> bcraGeneTestList) throws BaseException {
        if (log.isDebugEnabled()) log.debug("创建基因检测表 BcraGeneTestController");

        return bcraGeneTestService.saveModule(bcraGeneTestList);
    }

    @PostMapping("/updateGeneTest")
    @ApiOperation("修改基因检测")
    @ApiParam(value = "bcraGeneTestList")
    public ResultData update(@RequestBody List<BcraGeneTest> bcraGeneTestList) throws BaseException {
        if (log.isDebugEnabled()) log.debug("修改基因检测表 BcraGeneTestController");

        return bcraGeneTestService.updateModule(bcraGeneTestList);
    }

    @DeleteMapping("/deleteGeneTest")
    @ApiOperation("删除基因检测")
    @ApiParam(value = "问卷编号")
    public ResultData delete(String questionnaireCode) throws BaseException{
        if (log.isDebugEnabled()) log.debug("删除基因检测表 BcraGeneTestController");

        return bcraGeneTestService.removeByQuesCode(questionnaireCode);
    }

    @GetMapping("/getGeneTest")
    @ApiOperation("查看基因检测")
    @ApiParam(value = "问卷编号")
    public ResultData list(String questionnaireCode) throws BaseException{
        if (log.isDebugEnabled()) log.debug("删除基因检测表 BcraGeneTestController");

        return bcraGeneTestService.selectByQuesCode(questionnaireCode);
    }
}

